<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		li{
			margin: 5px 0;
		}

		a{margin:0 15px;}
	</style>
	<script type="text/javascript">
		window.onload=function(){
			var reg=document.getElementById('reg');
			var box=document.getElementById('box');
			var button=document.getElementById('button');

			button.onclick=function(){
			var li=document.createElement('li');
            var aLis=box.getElementsByTagName('li');

               li.innerHTML='<input value="" name="" type="text" /><a href="javascript:;">删除</a>';
               if (li.length>0) {
                box.insertBefore(li,aLis);
               }else{
               	box.appendChild(li);
               }
               


		            var as=document.getElementsByTagName('a');
		            for (var i = 0 ; i < as.length ; i++) {
		            	as[i].onclick=function(){
		            		box.removeChild(this.parentNode);
		            	}
		            }


			}
            



		}
	</script>
</head>
<body>
	<form id="reg">
		<input type="button" id="button" value="插入一行" name="">
		<ul id="box">
			
		</ul>
	</form>
</body>
</html>